#include <iostream>
#include <string>
#include <vector>

using namespace std;


int leastEdit(string a, string b){
    int m = a.size(), n = b.size();
    vector<vector<int>> dp(m+1, vector<int>(n+1));

    for(int i = 0; i <= m; i++) dp[i][0] = i;
    for(int i = 0; i <= n; i++) dp[0][i] = i;

    for(int i = 1; i <= m; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            dp[i][j] = min(dp[i][j - 1], dp[i - 1][j]) + 1;  // 添加 和 删除 
            dp[i][j] = min(dp[i][j], dp[i-1][j-1] + (a[i - 1] != b[j - 1])); // 替换和 啥也不做
        }
    }
    return dp[m][n];
}


int main(){
    string s1, s2;

    cin >> s1 >> s2;
    cout << leastEdit(s1, s2);

    return 0;

}

